package com.imcoke.abchat.common.utils;

import com.imcoke.abchat.web.mapper.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Calendar;

/**
 * @Author ccoke
 * @Description
 * @Date: 15:52 2017-11-30
 */
@Component
public class TimeManagerUtil {
    @Autowired
    private LogMapper mLogMapper;
    //定时清理日志 每个星期天1:00执行
    @Scheduled(cron = "0 0 1 * * 1")
    public void clearLog(){
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH,calendar.get(Calendar.MONTH)-3);
        mLogMapper.deleteLogsBeforeThreeMonth(calendar.getTime());
    }
}
